package pl.zuiol.games.poker.util;

import pl.zuiol.games.poker.util.Card;
import pl.zuiol.games.poker.util.Rank;
import pl.zuiol.games.poker.util.Suit;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * User: Damian Pezda
 * Date: 15.05.11
 * Time: 22:44
 */
public class Deck {

    private List<Card> cards;

    public Deck(){

        List<Card> temp_cards = new ArrayList<Card>();
        for (Rank rank : Rank.values()){
            for(Suit suit : Suit.values()){
                temp_cards.add(new Card(rank, suit));
            }
        }

        Random generator = new Random();

        cards = new ArrayList<Card>();
        while(temp_cards.size() > 0){
            cards.add(temp_cards.remove(generator.nextInt(temp_cards.size())));
        }
    }

    public int getDeckSize(){
        return this.cards.size();
    }

    public boolean isEmpty(){
        if(this.getDeckSize() > 0)
            return false;
        else return true;
    }

    public Card drawFromDeck(){
        return cards.remove(0);
    }
}
